import { Type } from "class-transformer";
import { IsInt, Min } from "class-validator";
import { BaseEntity } from "./BaseEntity";

export class SearchCondition extends BaseEntity {
    /**
     * 页面，从1开始
     */
    @IsInt({ message: '页码必须是整数' })
    @Min(1, { message: '页面最小值为1' })
    @Type(() => Number)
    public page: number = 1;

    /**
     * 页容量
     */
    @IsInt({ message: '页容量必须是整数' })
    @Min(1, { message: '页容量最小值为1' })
    @Type(() => Number)
    public limit: number = 10;

    /**
     * 搜索关键字
     */
    public key: string = ''

    /**
 *  # 将一个平面对象转换为一个Movie对象
 *  @param plainObject  
 *  @returns 
 */
    public static transform(plainObject: object): SearchCondition {
        return super.baseTransform(SearchCondition, plainObject)
    }
}